package BeenChina.PM.Util; 

import java.util.EnumSet;
public enum Permission {
	
	/*日常 1*/
	CaseNumberQuery( new PermissionItem("11","案件枚数検索","caseNumberQuery.action",NavMenu.DaliyInfo,PermissionItemType.table,"")),
	
	EmpInfoWorkEmpQuery( new PermissionItem("12","在職人数検索","empInfoWorkEmpQuery.action",NavMenu.DaliyInfo,PermissionItemType.table,"")),
	
	CaseRankInfoQuery( new PermissionItem("13","権限付与情報検索","caseRankInfoQuery.action",NavMenu.DaliyInfo,PermissionItemType.table,"案件各工程権限分配状況")),
	
 
	/*案件 2*/
	BaseInfoQuery(new PermissionItem("21","基礎情報検索","baseInfoQuery.action",NavMenu.CaseInfo,PermissionItemType.table,"")) ,
	/*运用 3*/
	
	/*生产 4*/
	CaseNumberEfficiencyQuery( new PermissionItem("41","案件生産情報検索","caseNumberEfficiencyQuery.action",NavMenu.ProductionInfo,PermissionItemType.chart,"案件別月別生産性の変化情報")), 
	
	/*DayRUtilizationQuery( new PermissionItem("42","実稼働状況集計「月」","dayRUtilizationQuery.action",NavMenu.ProductionInfo,PermissionItemType.chart,"")),
	TimeRUtilizationQuery( new PermissionItem("43","実稼働状況集計「日」","timeRUtilizationQuery.action",NavMenu.ProductionInfo,PermissionItemType.chart,"")),
	WeekRUtilizationQuery( new PermissionItem("44","実稼働状況集計「週」","weekRUtilizationQuery.action",NavMenu.ProductionInfo,PermissionItemType.chart,"")),*/
	
	UtilizationQuery( new PermissionItem("45","実稼働状況集計","utilizationQuery.action",NavMenu.ProductionInfo,PermissionItemType.chart,"日別、曜日別、月別稼動率情報")),
	
	CalculateQuery( new PermissionItem("46","要員計画検索","calculateQuery.action",NavMenu.ProductionInfo,PermissionItemType.chart,"オペレータリソース状況予測")),
	
	CaseCostQuery( new PermissionItem("47","案件コスト状況・一覧","caseCostQuery.action",NavMenu.ProductionInfo,PermissionItemType.chart,"運用関連コスト情報①")),
	
	CaseCostDetailQuery( new PermissionItem("48","案件コスト状況・詳細","caseCostDetailQuery.action",NavMenu.ProductionInfo,PermissionItemType.chart,"運用関連コスト情報②")),
	
	QualityCheckQuery( new PermissionItem("49","サンフルチェック検索","qualityCheckQuery.action",NavMenu.ProductionInfo,PermissionItemType.chart,"")),

	EmpAdjustBaseInfoQuery( new PermissionItem("4A","要員調整資料検索","empAdjustBaseInfoQuery.action",NavMenu.ProductionInfo,PermissionItemType.table,"月予定要員人数及び稼働情報")),
	
	/*品质 5*/
	ErrorChildImageManage( new PermissionItem("51","検証状況資料・設定","errorChildImageManage.action",NavMenu.QualityInfo,PermissionItemType.chart,"検証情報の判定、編集")),
	ErrorChildImageQuery( new PermissionItem("52","検証状況資料・検索","errorChildImageQuery.action",NavMenu.QualityInfo,PermissionItemType.chart,"検証結果検索")),
	
	/*系统 6*/
	RoleInfo( new PermissionItem("61","ロール情報検索","roleInfoQuery.action",NavMenu.SystemInfo,PermissionItemType.table,"")),
	UserInfo( new PermissionItem("62","ユーザー情報検索","userInfoQuery.action",NavMenu.SystemInfo,PermissionItemType.table,"")),
	
	
	/*export*/
	
	EmpInfoWorkEmpExport( new PermissionItem("121","在職人数・エクスポート","",NavMenu.DaliyInfo,PermissionItemType.export,"")),
	CaseRankInfoExport( new PermissionItem("131","権限付与情報検索・エクスポート","",NavMenu.DaliyInfo,PermissionItemType.export,"")),
	
	CaseNumberEfficiencyExport( new PermissionItem("411","案件生産情報・エクスポート","",NavMenu.ProductionInfo,PermissionItemType.export,"")),
	UtilizationExport( new PermissionItem("451","実稼働状況集計・エクスポート","",NavMenu.ProductionInfo,PermissionItemType.export,"")),
	CalculateExport( new PermissionItem("461","要員計画・エクスポート","",NavMenu.ProductionInfo,PermissionItemType.export,"")),
	CaseCostExport( new PermissionItem("471","案件コスト状況・一覧・エクスポート","",NavMenu.ProductionInfo,PermissionItemType.export,"")),
	CaseCostDetailExport( new PermissionItem("481","案件コスト状況・詳細・エクスポート","",NavMenu.ProductionInfo,PermissionItemType.export,"")),
	QualityCheckExport( new PermissionItem("491","サンフルチェック・エクスポート","",NavMenu.ProductionInfo,PermissionItemType.export,"")),
	EmpAdjustBaseInfoExport( new PermissionItem("4A1","要員調整資料・エクスポート","",NavMenu.ProductionInfo,PermissionItemType.export,"")),
	
	ErrorChildImageExport( new PermissionItem("521","検証状況資料・索・エクスポート","",NavMenu.QualityInfo,PermissionItemType.export,"")),
	ErrorChildImageDownLoad( new PermissionItem("522","検証状況資料・イメージ・エクスポート","",NavMenu.QualityInfo,PermissionItemType.export,"")),
	;
	
	private PermissionItem item;

	Permission(PermissionItem item){
		this.item = item;
	 }

	public PermissionItem getItem(){
		return this.item;
	 }
	
	 
	
	public static String getItemID(String permissionNames)
	{
		EnumSet<Permission> p = EnumSet.allOf(Permission.class);
		if (permissionNames==null) return "";
		String per[] = permissionNames.split(",");
		
		String result ="";
		for(int i=0;i<per.length;i++)
		{
			for (Permission x : p) {
				if ( per[i].equals(x.getItem().getName()))
				{					
				    if (result.length()>0)
					  result += ",";
					 
					result += x.getItem().getId();
				}
			 }
		} 
		return result;
	}
	
	public static String getItemName(String permissionIds)
	{
		EnumSet<Permission> p = EnumSet.allOf(Permission.class);
		if (permissionIds==null) return "";
		String per[] = permissionIds.split(",");
		
		String result ="";
		for(int i=0;i<per.length;i++)
		{	 
			for (Permission x : p) 
			{ 
				if ( per[i].equals(x.getItem().getId()))
				{	
					 if (result.length()>0)
						 result += ",";
					 
					 result += x.getItem().getName();
					 
				}
			 }
		}
 
		return result;
		 
	}
	
	//���ȫ����Ȩ���б�
	public static String getPremissionsNameString()
	{
	   EnumSet<Permission> p = EnumSet.allOf(Permission.class);
	  
	   String result="" ;
	    for (Permission x : p) 
	    {				 
		  if (result.length()>0)
			 result += ",";
		 
		 result += x.getItem().getName();
		 }
			 
			 
		return	result;
	}
	
	 /*ͨ��ID�õ�ö���б�*/
	public static EnumSet<Permission> getPremissions(String permissionIds)
	{
		EnumSet<Permission> result = EnumSet.noneOf(Permission.class);
		
		EnumSet<Permission> p = EnumSet.allOf(Permission.class);
		if (permissionIds==null) return null;
		String per[] = permissionIds.split(",");
		
		 
		for(int i=0;i<per.length;i++)
		{	 
			for (Permission x : p) 
			{ 
				if ( per[i].equals(x.getItem().getId()) && ! x.getItem().getItemType().equals(PermissionItemType.export))
				{	 
					result.add(x); 
				}
			 }
		} 
		return result;		 
		 
	}
	
	public static String getActionName(String action)
	{
		EnumSet<Permission> p = EnumSet.allOf(Permission.class);
		if (action==null) return "";
 
		
		String result ="";
		 	 
			for (Permission x : p) 
			{ 
				if ( action.equals(x.getItem().getAction()))
				{	 
					 result  = x.getItem().getName();
					 break;
				}
			 }
	 
		return result;
		 
	}
	 
}
